import * as React from 'react'
import classNames from 'classnames'
import './style/index.less'
import { DividerProps, DividerState } from './interface'

class Divider extends React.Component<DividerProps, DividerState> {

  static defaultProps = {
    prefixCls: 'addon-layui-divider',
    type: 'horizontal',
    orientation: 'center'
  }

  render() {
    const {
      prefixCls, children, dashed, orientation,
      type, className, text,
      ...restProps
    } = this.props

    const classes = classNames(prefixCls, className, {
      [`${prefixCls}-${type}`]: type,
      [`${prefixCls}-with-text`]: type == 'horizontal' && text,
      [`${prefixCls}-with-text-${orientation}`]: type == 'horizontal' && text && orientation
    })

    return (
      <div className={classes} {...restProps}>
        {type == 'horizontal' ? <span className={`${prefixCls}-inner-text`}>{text}</span> : ''}
      </div>
    )
  }
}

export default Divider